//
//  TradesCell.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/14.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "TradesCell.h"

@interface TradesCell()

@property(nonatomic,strong)UILabel *createName;
@property(nonatomic,strong)UILabel *createName1;
@property(nonatomic,strong)UILabel *orderNo;
@property(nonatomic,strong)UILabel *totalMoney;
@property(nonatomic,strong)UILabel *totalMoney1;
@property(nonatomic,strong)UILabel *status;
@property(nonatomic,strong)UILabel *itemTypes;
@property(nonatomic,strong)UILabel *itemTypes1;
@property(nonatomic,strong)UILabel *createDate;
@property(nonatomic,strong)UILabel *createDate1;
@property(nonatomic,strong)UILabel *lineLabel;
@end
@implementation TradesCell

- (void)awakeFromNib {
   
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        [self createView];
        [self setViewAutoLayout];
    }
    
    return self;
    
}
-(void)createView
{
    
    self.backgroundColor=[UIColor whiteColor];
    self.orderNo=[[UILabel alloc] init];
    self.orderNo.font= [UIFont systemFontOfSize:17];
    self.orderNo.textColor=[UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0];
    [self addSubview:self.orderNo];
    
    self.status=[[UILabel alloc] init];
    self.status.font= [UIFont systemFontOfSize:13];
    self.status.textColor=luseColor;
    [self addSubview:self.status];
    
    self.createName=[[UILabel alloc] init];
    self.createName.font= [UIFont systemFontOfSize:14];
    self.createName.text=@"员工";
    self.createName.textColor=zhonghuiColor;
    [self addSubview:self.createName];
    self.createName1=[[UILabel alloc] init];
    self.createName1.font= [UIFont systemFontOfSize:14];
    self.createName1.textColor=shenhuiColor;
    [self addSubview:self.createName1];
    
    self.createDate=[[UILabel alloc] init];
    self.createDate.font= [UIFont systemFontOfSize:14];
    self.createDate.text=@"日期";
    self.createDate.textColor=zhonghuiColor;
    [self addSubview:self.createDate];
    self.createDate1=[[UILabel alloc] init];
    self.createDate1.font= [UIFont systemFontOfSize:14];
    self.createDate1.textColor=shenhuiColor;
    [self addSubview:self.createDate1];
   
    
    self.itemTypes=[[UILabel alloc] init];
    self.itemTypes.font= [UIFont systemFontOfSize:14];
    self.itemTypes.text=@"购买";
    self.itemTypes.textColor=zhonghuiColor;
    [self addSubview:self.itemTypes];
    
    self.itemTypes1=[[UILabel alloc] init];
    self.itemTypes1.font= [UIFont systemFontOfSize:14];
    self.itemTypes1.textColor=shenhuiColor;
    [self addSubview:self.itemTypes1];
    
    self.totalMoney=[[UILabel alloc] init];
    self.totalMoney.font= [UIFont systemFontOfSize:14];
    self.totalMoney.text=@"金额 ¥ ";
    self.totalMoney.textColor=zhonghuiColor;
    [self addSubview:self.totalMoney];
    self.totalMoney1=[[UILabel alloc] init];
    self.totalMoney1.font= [UIFont systemFontOfSize:14];
    self.totalMoney1.textColor=shenhuiColor;
    [self addSubview:self.totalMoney1];
    
    
    self.lineLabel=[[UILabel alloc] init];
    [self.lineLabel setBackgroundColor:[UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
    self.lineLabel.textColor=[UIColor clearColor];
    [self addSubview:self.lineLabel];
    

}
-(void)setModel:(TradesModel *)model
{
    
self.orderNo.text=[NSString stringWithFormat:@"%@",  model.orderNo];
self.createName1.text=[NSString stringWithFormat:@"%@",  model.memberName];
    NSRange range={0,10};
    NSString* string =[model.orderDate substringWithRange:range];
self.createDate1.text=[NSString stringWithFormat:@"%@", string];
if ([ model.orderType isEqualToString:@"other"]) {
        if ([model.orderStatus isEqualToString:@"Y"]) {
                self.status.text=@"自定义收全款";
    }
        self.itemTypes.text=[NSString stringWithFormat:@"%@", @"直接收款"];
        self.itemTypes1.text=@"";

     }
  
 if ([ model.orderType isEqualToString:@"order"]) {
   
        if ([model.orderStatus isEqualToString:@"C"]) {
                self.status.textColor=luseColor;
                self.status.text=@"已取消";
            }if ([model.orderStatus isEqualToString:@"P"]) {
                self.status.textColor=luseColor;
                self.status.text=@"收定金";
            }
            if ([model.orderStatus isEqualToString:@"N"]) {
               self.status.textColor=[UIColor colorWithRed:4/255.00 green:184/255.00 blue:149/255.00 alpha:1.0];
                self.status.text=@"未收款";
            }
            if ([model.orderStatus isEqualToString:@"Y"]) {
                self.status.textColor=luseColor;
    
                self.status.text=@"收全款";
            }
    
            self.itemTypes.text=@"购买";
            self.itemTypes1.text=[NSString stringWithFormat:@"%@ %@件",model.itemTypes,model.totalQuantity];
     
     }

     if ([ model.orderType isEqualToString:@"service"]) {
    
        self.status.text=model.serviceType;
        self.itemTypes.text=@"服务";
        self.itemTypes1.text=[NSString stringWithFormat:@"%@ %@件",model.itemTypes,model.totalQuantity];

    }

    if ([ model.orderType isEqualToString:@"refund"]) {
        self.status.text=model.reasonType;
        self.itemTypes.text=@"退货";
        self.itemTypes1.text=[NSString stringWithFormat:@"%@ %@件",model.itemTypes,model.totalQuantity];
        }

    
    
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",model.realMoney];
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
        self.totalMoney1.text=[NSString stringWithFormat:@"%@", formattedNumberString];
    
}
-(void)setViewAutoLayout
{
    [self.orderNo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@17);
        make.top.equalTo(self.mas_top).with.offset(25);
    }];
    
    [self.status mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderNo.mas_right).with.offset(3);
        make.top.equalTo(self.mas_top).with.offset(26.5);
    }];
  
    
    [self.createName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@14);
        make.top.equalTo(self.orderNo.mas_bottom).with.offset(15);
    }];
    
    [self.createName1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.createName.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.createName.mas_centerY) ;
        
    }];
    [self.createDate mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.createName1.mas_right).with.offset(15);
        
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.createName.mas_centerY) ;

    }];
    
    [self.createDate1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.createDate.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.createDate.mas_centerY) ;
        
    }];
    
    
    [self.itemTypes mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@14);
        make.top.equalTo(self.createDate1.mas_bottom).with.offset(5);
    }];
    
    [self.itemTypes1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.itemTypes.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.itemTypes.mas_centerY) ;
        
    }];
    
    [self.totalMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        
       make.left.equalTo(self.itemTypes1.mas_right).with.offset(15);
        make.height.equalTo(@14);
         make.centerY.equalTo(self.itemTypes.mas_centerY) ;
    }];
    
    [self.totalMoney1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.totalMoney.mas_right).with.offset(0);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.itemTypes.mas_centerY) ;

        
    }];

    
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(10);
        make.right.equalTo(self.mas_right).with.offset(-10) ;
        
        make.height.equalTo(@1);
        
        make.top.equalTo(@108).with.offset(0);
    }];
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
